-
Notifications
You must be signed in to change notification settings - Fork 160
Fix func build/deploy validation: Add early validation for conflicting --image and --registry flags #3066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @RayyanSeliya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3066 +/- ##
==========================================
+ Coverage 58.66% 59.47% +0.80%
==========================================
Files 133 133
Lines 17120 17153 +33
==========================================
+ Hits 10044 10202 +158
+ Misses 6146 5992 -154
- Partials 930 959 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I think i am missing some edge cases @gauron99 @lkingland please point out if any the test are still failing :( |
im gonna take a look tomorrow |
Sure no worries !! Good night ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we could simply check that -registry and --image are not given together at all? Image takes precedence now which is correct. But we want to avoid having the need to remove FUNC_REGISTRY
or your registry in config file when trying to once specify --image
for a different registry.
In other words --image
should just take precedence and work even when FUNC_REGISTRY
is specified BUT --image
and --registry
could just return an error saying "just choose one or the other" for simplicity?
Otherwise you would need to check both registries, determine what parts image contains and prepend (which I dont think works currently? check my other comment) and that would require a bit more work and consideration.
@lkingland WDYT?
cmd/build.go
Outdated
// Skip validation if image has digest (@sha256:...) - digests are immutable overrides | ||
if !strings.Contains(c.Image, "@sha256:") { | ||
// Only validate if image has explicit registry (contains "/" or ":") | ||
// Simple names like "myimage" are compatible - registry will be prepended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are they really prepended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❯ func build --image mine --registry quay.io/dfridric
Building function image
Still building
🙌 Function built: mine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gauron99 u are right! The old validation was confusing , your test showed that --image override/takes precedence --registry, which wasn’t clear to users. We’ve fixed this by rejecting both flags when used together and showing a clear error message.
I agree with @gauron99 on this one. Please simply check if the flags were both provided, and then raise an error that only one or the other should be provided, not both. 👍🏻 |
…between image and registry with different specified resgistry Signed-off-by: RayyanSeliya <[email protected]>
…ding both flags together with clear error message Signed-off-by: RayyanSeliya <[email protected]>
73b89f5
to
002fd40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this already looks cleaner and simpler. I added a comment about one test
// resultant image member is updated but the registry member is not | ||
// updated (subsequent builds will not be affected). | ||
// Image flag sets the image directly when no registry is present | ||
name: "image flag overrides", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this test we want to test exactly the case where image DOES override registry since registry is not being provided via flag but rather its already been given previously.
This test seems to to to cover the case when you
func deploy --registry ...
... nowf.registry
exists infunc.yaml
and is not emptyfunc deploy --image <different image>
we want this case to work -> override the image from registry
thats been used from 1.
with image
from 2.
the func.yaml
registry is NOT overriden and kept as is from 1.
but the new image is used in deployment because --image
was provided with different value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for the clarification @gauron99 i have updated to included this test too ...
Signed-off-by: RayyanSeliya <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold to make sure @gauron99 your OK too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/unhold
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gauron99, lkingland, RayyanSeliya The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
/kind enhancement
Fixes #3065
Solution:
Implement a 2-layer error system:
ErrConflictingImageAndRegistry
from validation inpkg/functions/errors.go
cmd/build.go
andcmd/deploy.go
and wrap with user-friendly guidanceImplementation Details:
buildConfig.Validate()
anddeployConfig.Validate()
methodsstrings.HasPrefix()
to check if image starts with registry (allows subnamespaces)Release Note